/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Student
 */
public class Connector {

    private String url = "jdbc:derby://localhost:1527/iTunes;user=root;password=root";
    private Connection conn;

    /**
     * instantiates the class
     */
    public Connector() {
        try {
            //set driver
            Class.forName("org.apache.derby.jdbc.ClientDriver");

            //open connection
            conn = DriverManager.getConnection(url);
        } catch (SQLException ex) {
            Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    /**
     * returns a connection to the databse
     *
     * @returns connection
     */
    public Connection getConn() {
        return conn;
    }

    /**
     * sets a connection to the databse
     *
     * @param conn
     */
    public void setConn(Connection conn) {
        this.conn = conn;
    }
}
